#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 3000;

int n;
LL q[N];


int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);



    int T;
    cin >> T;
    while(T--){
        cin >> n;
        for(int i = 1; i <= n; i ++) cin >> q[i];

        LL minv = 1e18;

        for(int i = 1; i <= n; i ++){
            minv = min(minv, q[i]);
        }

        if(minv == 1){
            LL res = 0;
            for(int i = 1; i <= n; i ++){
                res = (LL) res + q[i] - 1;
            }
            cout << res << '\n';
            continue;
        }
        
        minv = minv * 2 - 1;
        LL res = 0;
        for(int i = 1; i <= n; i ++){
            int k = q[i] / minv;
            if(q[i] % minv == 0) k--;
            res += k;
        }

        cout << res << '\n';
    }

    return 0;
}